//
//  WLTabBarController.m
//  WanLian
//
//  Created by muzhuang on 2018/8/27.
//  Copyright © 2018年 wanlian. All rights reserved.
//

#import "WLTabBarController.h"
#import "WLHomeViewController.h"
#import "WLRouterViewController.h"
#import "WLSettingViewController.h"

//#import "WLloginController.h"
//#import "WLRouterBingFlowController.h"

@interface WLTabBarController ()

@end

@implementation WLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tabBar.translucent = NO;
    [self addChildViewControllers];
    
//    if (1) {
//        WLloginController *loginController = [[WLloginController alloc] init];
//        [self presentViewController:[[UINavigationController alloc] initWithRootViewController:loginController] animated:NO completion:nil];
//    }
//    if (1) {
//        WLRouterBingFlowController *flowController = [[WLRouterBingFlowController alloc] init];
//        [self presentViewController:[[UINavigationController alloc] initWithRootViewController:flowController] animated: NO completion:nil];
//    }
}

- (void)addChildViewControllers
{
    WLHomeViewController *homeController = [[WLHomeViewController alloc] init];
    UINavigationController *homeNav = [self addOneChildVc:homeController title:@"首页" image:@"tabbar_home_normal" selectedImage:@"tabbar_home_selected"];
    WLRouterViewController *routerController = [[WLRouterViewController alloc] init];
    UINavigationController *routerNav = [self addOneChildVc:routerController title:@"路由管理" image:@"tabbar_router_normal" selectedImage:@"tabbar_router_selected"];
    WLSettingViewController *settingController = [[WLSettingViewController alloc] init];
    UINavigationController *settingNav = [self addOneChildVc:settingController title:@"我的" image:@"tabbar_mine_normal" selectedImage:@"tabbar_mine_selected"];
    self.viewControllers = @[homeNav,routerNav,settingNav];
}

- (UINavigationController *)addOneChildVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    // 设置文字和图片
    vc.navigationItem.title = title;
    vc.title = title;
    vc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    return nav;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
